/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author anhvtn_b00545
 */
public class loadOrder extends AbstractTableModel{
    private int COLUMNS = 3;
    private List<Bill_BS> list;

     public loadOrder(List<Bill_BS> list) {
        this.list = list;
    }
    public int getRowCount() {
        return list.size();
    }

    public int getColumnCount() {
        return COLUMNS;
    }

 @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0 : return "Order Code";
            case 1 : return "Customer Name";
            case 2 : return "Order Date";

        }
        return null;
    }
    public Object getValueAt(int rowIndex, int columnIndex) {
        Bill_BS b = list.get(rowIndex);
        switch(columnIndex) {
            case 0 : return b.getBID();
            case 1 : return b.getCName();
            case 2 : return b.getBdate();

        }
        return null;
    }
    public void addOrder(List<Bill_BS> ls)    {
        list = ls;
        this.fireTableDataChanged();
    }

    public Bill_BS getPurchaseBS(int index) {
        return list.get(index);
    }
     public void deletePurchaser(Bill_BS order) {
        list.remove(order);
        fireTableDataChanged();
    }
}
